package com.wuyou.simple;

/**
 * 2299. 强密码检验器 II
 */
public class StrongPasswordCheckerII {

    public static void main(String[] args) {
        String password = "11A!A!Aa";

        System.out.println(solution_1(password));
    }

    public static boolean solution_1(String password){
        if(password.length() < 8) return false;
        int[] res = new int[6];
        res[0] = 1;
        String s = "!@#$%^&*()-+";
        for(int i = 0; i < password.length(); i++){
            char c = password.charAt(i);
            if(c >= 'a'  && c <= 'z') res[1] = 1;
            if(c >= 'A'  && c <= 'Z') res[2] = 1;
            if(c >= '0'  && c <= '9') res[3] = 1;
            if(s.indexOf(c) != -1) res[4] = 1;
            if(i < password.length() - 1){
                if(c == password.charAt(i + 1)) {
                    return false;
                }else{
                    res[5] = 1;
                }
            }else{
                res[5] = c == password.charAt(i - 1) ? 0 : 1;
            }
        }
        for(int i = 1; i <res.length; i ++ ){
            if(res[i - 1] != res[i]) return false;
        }
        return true;
    }
}
